import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { OverDetailsPage } from "../over-details/over-details";
import { localbase} from '../../models/localbase';
import { QueOutput, AnswerLog, AnswerLogUp, MobileAnswer, MobileAnserChd } from '../../models/quesinfo';

/**
 * Generated class for the QuestionCompletionPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-over-view',
  templateUrl: 'over-view.html',
})
export class OverViewPage {
  questionStatus = 'all';
  _fqid;
  _list = [];
  _tname;
  numw;
  numz;
  numy;
  numall;
  W=0;
  Y=0;
  Z=0;
  ALL=0;
  constructor(public navCtal: NavController,
    public localbasefun: localbase,
    public navParams: NavParams,
    public navCtrl: NavController,
  ) { }
  ngOnInit(): void {
    this._fqid = this.navParams.get("_fqid");
    // this._fqid='f03ed3ba-68c3-465c-86b8-fec843567b99';
    this.datas(this._fqid);

  }
  async datas(a) {
    this._list = await this.localbasefun.getbaseAnswerlogByFQId(a);
    if (this._list.length < 1) {
      this._tname = "此问卷没有记录";
      this.numw = '0';
      this.numz = '0';
      this.numy = '0';
      this.numall = '0';
    } else {
      this._tname = this._list[0].FTitle;
      this.ALL = this._list.length;
      this._list.forEach((item, a) => {
        if (item.FUpdateloadState == -1) {
          this.Z+=1;
        }
        if (item.FUpdateloadState == 1) {
          this.W+=1;
        }
        if (item.FUpdateloadState == 2) {
          this.Y+=1;
        }
      })
    }
  }

  ionViewDidLoad() {

  }
  async OverDetails(answerid,num) {
    let param = { FQID: this._fqid };
    let localbasefun = this.localbasefun;
    let ss = await this.localbasefun.getQueByFqidEdit(answerid);
    this.navCtrl.push("OverDetailsPage", { resData: <QueOutput>ss, s: '-1', answerid: answerid ,num:num});
  }

}
